class Image
# initialization {{{
	def initialize(file,winWidth,winHeight,zoom=1,xpos=0,ypos=0)
		file=@file
		@winWidth=winWidth
		@winHeight=winHeight
		@zoom=zoom
		@xpos=xpos
		@ypos=ypos
	end
#}}}

	def resize (winWidth,winHeight) #{{{
			if winWidth!=@winWidth or winHeight!=@winHeight
			pixWidth=@pixbuf.width.to_f
			pixHeight=@pixbuf.height.to_f
			@winWidth=winWidth
			@winHeight=winHeight
			scale=[@winWidth/pixWidth,@winHeight/pixHeight].min
			scale=scale*@zoom
			if @zoom<=1
				@imageScale.pixbuf=@pixbuf.scale(scale*pixWidth,scale*pixHeight,Gdk::Pixbuf::INTERP_BILINEAR)
			else
				tmpPixWidth=[pixWidth,@winWidth/scale].min
				tmpPixHeight=[pixHeight,@winHeight/scale].min
				@xpos=pixWidth/2-tmpPixWidth/2 if (pixWidth/2-tmpPixWidth/2+@xpos)>(pixWidth-tmpPixWidth)
				@ypos=pixHeight/2-tmpPixHeight/2 if (pixHeight/2-tmpPixHeight/2+@ypos)>(pixHeight-tmpPixHeight)
				@xpos=-pixWidth/2+tmpPixWidth/2 if (pixWidth/2-tmpPixWidth/2+@xpos)<0
				@ypos=-pixHeight/2+tmpPixHeight/2 if (pixHeight/2-tmpPixHeight/2+@ypos)<0
				x=pixWidth/2-tmpPixWidth/2+@xpos
				y=pixHeight/2-tmpPixHeight/2+@ypos
				tmpPixbuf=Gdk::Pixbuf.new(@pixbuf,x,y,tmpPixWidth,tmpPixHeight)
				@imageScale.pixbuf=tmpPixbuf.scale(scale*tmpPixWidth,scale*tmpPixHeight,Gdk::Pixbuf::INTERP_BILINEAR)
			end
			Gtk.main_iteration
			end
			GC.start
	end
#}}}
end
